<?php session_start();
include 'connect.php';?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<link rel="stylesheet" type="text/css" href="styles.css"/>

	<title>Current Projects</title>
	<meta name="generator" content="BBEdit 9.5" />
<!-- jquery validation -->	
	
</head>
<body>
<div class="logo"></div> 
<div id="containerProjects">
<div id="MainContent">
<div id="user">
<?php
				if (isset($_SESSION['MemberID'])){
					echo "Hi, ".$_SESSION['Username'].".<br />";
				}
				?>

<?php if (isset($_SESSION['MemberID'])){ echo "<a href='logout.php'>Logout</a>";}?>
</div>
<div class="clear"></div>

<div class="linksContainer">

<?php
//print_r($_SESSION['MemberID']);
if(isset($_SESSION['MemberID'])){
	
	echo "<a href='welcome.php' class='links'>Home Page</a>";
	echo "<a href='memberProfile.php' class='links'>My Profile</a>";
	echo "<a href='memberProjects.php' class='links'>My Projects</a>";
	echo "<a href='projMan.php' class='links'>View Current Projects</a>";
	echo "<a href='createProject.php' class='links'>Create a Project</a>";

			}
	else echo "Please <a href='index.php'>login</a> to access this page.";

//connect to the database
if(!@mysql_select_db('projectmanager'))
{
	exit("<p>The Projectmanager database isn't loading. Try something else.</p>");
}

$projList = @mysql_query('SELECT DISTINCT m.Name, p.ProjectName, p.Description FROM members m, project p WHERE m.MemberID = p.CreatorID;');
if(!$projList){
	exit('<p>There was a problem with the query:'.mysql_error().'</p>');
}


		//$creator = mysql_query("SELECT DISTINCT m.Name, p.ProjectName, p.Description FROM members m, project p WHERE m.MemberID = p.CreatorID;");
		//$creatorList = mysql_fetch_array($creator);

//Run the sequence
while($row = mysql_fetch_array($projList))
	{
		//$memberDetails = mysql_query("SELECT Name FROM members m, members_has_project j,project p WHERE m.MemberID = j.Members_MemberID AND p.ProjectID = j.Project_ProjectID");
		
		echo "<div class='mainBox'>";
			echo "<div class='projTitle'><h1>" .$row['ProjectName']."</h1></div>";
			echo "<div class='creator'> <h4>Project Creator:".$row['Name']."</h4></div>";
			echo "<div class='desc'>".$row['Description']."</div>";
			
			echo"<div class='memberholder'> <span class = 'members'>Members involved: |</span>";
				
				/*while($member = mysql_fetch_array($memberDetails)){
					$name = $member['Name'];*/
					echo"<span class = 'members'>&nbsp name | </span>";
					echo "</div></div>";
		
	}
	//the menu
$projMenu = mysql_query("SELECT ProjectName, ProjectID FROM project");
$options=""; 
	
while($row = mysql_fetch_array($projMenu)){

	$id=$row["ProjectID"]; 
    $projName=$row["ProjectName"]; 
    $options.="<option value='$projName'>".$projName."</OPTION>"; 
}
?>
<form name="editProj" action="editProj.php" method="post">
<select name ="projMenu">
<option value = "">Choose Project</option>
<?php echo $options ?>
</select> 
<input type="submit" value="go" /> 
</form>

</body>
</html>